// 将浏览器地址栏隐藏
// http://blog.csdn.net/hbcui1984/article/details/8350107
setTimeout(function() {  
	window.scrollTo(0, 1);
}, 0);

function onOpenAppBtnClick_data(el){
	var id		 	= el.getAttribute('data-id');
	var typeId		= el.getAttribute('data-typeId');
	var feeFlag 	= el.getAttribute('data-dataFeeFlag');
	var sectionId	= el.getAttribute('data-sectionId');
	
	var openAppLink;
	switch(typeId){
		case "1":
			openAppLink = {
				ios : 'smcyuetv://contentId={0}&contentType={1}&sectionId={2}&feeCode={3}'.format(id, typeId, sectionId, feeFlag),
				android : 
'smc.ng.yuetv.a://VideoPlayerActivity/?contentId={0}&contentType={1}&sectionId={2}&feeCode={3}'.format(id, typeId, sectionId, feeFlag)
			};
		break;
		case "4":
			openAppLink = {
				ios : 'smcyuetv://contentId={0}&contentType={1}&sectionId={2}&feeCode={3}'.format(id, typeId, sectionId, feeFlag),
				android : 
'smc.ng.yuetv.a://BroadcastActivity/?contentId={0}&contentType={1}&sectionId={2}&feeCode={3}'.format(id, typeId, sectionId, feeFlag)
			};
		break;
		case "5":
			openAppLink = {
				ios : 'smcyuetv://contentId={0}&contentType={1}'.format(id, typeId),
				android : 
'smc.ng.yuetv.a://ArticleActivity/?contentId={0}&contentType={1}'.format(id, typeId)
			};
		break;
		case "6":
			openAppLink = {
				ios : 'smcyuetv://contentId={0}&contentType={1}'.format(id, typeId),
				android : 
'smc.ng.yuetv.a://GalleryActivity/?contentId={0}&contentType={1}'.format(id, typeId)
			};
		break;
	}
	
	onOpenAppBtnClick_url(openAppLink);
}
function onOpenAppBtnClick_url(openAppLink){
	var openAppLink = window.navigator.is_iOS ? openAppLink.ios : openAppLink.android;
	var downloadAppLink = window.navigator.is_iOS 
		? "itms-apps://itunes.apple.com/cn/app/id436107225?mt=8" : "../download/";
	onOpenAppBtnClick(openAppLink, downloadAppLink);
}

function onOpenAppBtnClick(openAppLink, downloadAppLink){
//	alert(el.getAttribute('data-id'));
	var iframe = document.getElementById('openAppIframe');
	if(!iframe){
		iframe = document.createElement('iframe');
		iframe.style="display:none;";
		iframe.src = 'about:blank';
		document.body.appendChild(iframe);
	}

	// 双管齐下
	iframe.src = openAppLink;
    setTimeout(function(){
    	window.location = downloadAppLink;
    }, 100);
}
define(function(require, exports, module) {
    
	// 平板的怎么样处理？如果屏幕尺寸很大，是否需拉伸图片

//	$.getImgWidthByPercentage = function (percentage){
//		var imgWidth = window.innerWidth / percentage;
//		
//		if(window.devicePixelRatio)
//			imgWidth *= window.devicePixelRatio;
//		
//		return parseInt(imgWidth);
//	}
	
	exports.provide = function(id, obj){
		provide[id] = obj;
	}
});